#include <cstdio>
#include <algorithm>
#include <cstring>
typedef long long ll;
using namespace std;
const int MOD=10000;
ll qPow(ll a,ll b){
    ll ans=1;
    while(b){
        if(b%2){
            ans=(ans*a)%MOD;
        }
        a=a*a%MOD;
        b/=2;
    }
    return ans;
}
int main(void){
    int t;
    ll n;
    scanf("%d",&t);
    while(t--){
        scanf("%lld",&n);
        printf("%lld\n",qPow(n,2)%MOD);
    }
    return 0;
}